﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Subjects.Dto;
using HOPU.OnlineSchool.Application.Subjects.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Subjects
{
    public class SubjectAppService : IDynamicApiController
    {
        private readonly ISubjectService _subjectService;

        public SubjectAppService(ISubjectService subjectService)
        {
            _subjectService = subjectService;
        }

        /// <summary>
        /// 获取课程分类树形数据
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpGet("api/subject")]
        public async Task<List<SubjectTreeDto>> GetSubjectTree()
        {
            return await _subjectService.GetSubjectTreeSync();
        }
        [AllowAnonymous]
        public async Task<string> Add(SubjectSubDto dto)
        {
            return await _subjectService.AddAsync(dto);
        }
        [AllowAnonymous]
        public async Task<string> DeleteAsync(string id)
        {
            return await _subjectService.DeleteAsync(id);
        }
    }
}
